package club.ruanx.spider.service.impl;

import club.ruanx.spider.entity.DoubanMovie;
import club.ruanx.spider.repository.DoubanMovieRepository;
import club.ruanx.spider.service.DoubanMovieService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

/**
 * @author 阮胜
 * @date 2018/11/26 14:29
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class DoubanMovieMovieServiceImpl implements DoubanMovieService {
    private final DoubanMovieRepository doubanMovieRepository;

    public DoubanMovieMovieServiceImpl(DoubanMovieRepository doubanMovieRepository) {
        this.doubanMovieRepository = doubanMovieRepository;
    }

    @Override
    public DoubanMovie save(DoubanMovie doubanMovie) {
        if (StringUtils.isEmpty(doubanMovie)) {
            return null;
        }
        return doubanMovieRepository.save(doubanMovie);
    }
}
